package com.shg.admin.service.impl;

import com.shg.admin.bean.City;
import com.shg.admin.mapper.CityMapper;
import com.shg.admin.service.CityService;
import io.micrometer.core.instrument.Counter;
import io.micrometer.core.instrument.MeterRegistry;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class CityServiceImpl implements CityService {
    
    private final CityMapper cityMapper;
    
    private Counter counter;
    

    public CityServiceImpl(CityMapper cityMapper, MeterRegistry meterRegistry) {
        this.cityMapper = cityMapper;
        counter = meterRegistry.counter("cityService.selectListCity.count");
    }

    @Override
    public City selectCityById(Long id) {
        return cityMapper.selectCityById(id);
    }

    @Override
    public List<City> selectListCity() {
        counter.increment();
        return cityMapper.selectListCity();
    }

    @Override
    public void insertCity(City city) {
        cityMapper.insertCity(city);
    }
}
